<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>QtWebApp: stefanfrings::Template Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">QtWebApp
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classstefanfrings_1_1Template.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classstefanfrings_1_1Template-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">stefanfrings::Template Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Enhanced version of QString for template processing.  
 <a href="classstefanfrings_1_1Template.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="template_8h_source.html">template.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for stefanfrings::Template:</div>
<div class="dyncontent">
<div class="center"><img src="classstefanfrings_1_1Template__inherit__graph.png" border="0" usemap="#astefanfrings_1_1Template_inherit__map" alt="Inheritance graph"/></div>
<map name="astefanfrings_1_1Template_inherit__map" id="astefanfrings_1_1Template_inherit__map">
<area shape="rect" title="Enhanced version of QString for template processing." alt="" coords="5,80,173,107"/>
<area shape="rect" title=" " alt="" coords="54,5,125,32"/>
</map>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for stefanfrings::Template:</div>
<div class="dyncontent">
<div class="center"><img src="classstefanfrings_1_1Template__coll__graph.png" border="0" usemap="#astefanfrings_1_1Template_coll__map" alt="Collaboration graph"/></div>
<map name="astefanfrings_1_1Template_coll__map" id="astefanfrings_1_1Template_coll__map">
<area shape="rect" title="Enhanced version of QString for template processing." alt="" coords="5,80,173,107"/>
<area shape="rect" title=" " alt="" coords="54,5,125,32"/>
</map>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a2b1b210dc7dac0ebe15f2ae4de6e0f89"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1Template.html#a2b1b210dc7dac0ebe15f2ae4de6e0f89">Template</a> (const QString source, const QString sourceName)</td></tr>
<tr class="memdesc:a2b1b210dc7dac0ebe15f2ae4de6e0f89"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor that reads the template from a string.  <a href="classstefanfrings_1_1Template.html#a2b1b210dc7dac0ebe15f2ae4de6e0f89">More...</a><br /></td></tr>
<tr class="separator:a2b1b210dc7dac0ebe15f2ae4de6e0f89"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a29a11e25a992928fb324671ee72a6f31"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1Template.html#a29a11e25a992928fb324671ee72a6f31">Template</a> (QFile &amp;file, const QTextCodec *textCodec)</td></tr>
<tr class="memdesc:a29a11e25a992928fb324671ee72a6f31"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor that reads the template from a file.  <a href="classstefanfrings_1_1Template.html#a29a11e25a992928fb324671ee72a6f31">More...</a><br /></td></tr>
<tr class="separator:a29a11e25a992928fb324671ee72a6f31"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6700fe0bdbf9955ad24f71bcba76604c"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1Template.html#a6700fe0bdbf9955ad24f71bcba76604c">setVariable</a> (const QString name, const QString value)</td></tr>
<tr class="memdesc:a6700fe0bdbf9955ad24f71bcba76604c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Replace a variable by the given value.  <a href="classstefanfrings_1_1Template.html#a6700fe0bdbf9955ad24f71bcba76604c">More...</a><br /></td></tr>
<tr class="separator:a6700fe0bdbf9955ad24f71bcba76604c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad04721f62e02a81b84a56413e72387ad"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1Template.html#ad04721f62e02a81b84a56413e72387ad">setCondition</a> (const QString name, bool value)</td></tr>
<tr class="memdesc:ad04721f62e02a81b84a56413e72387ad"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set a condition.  <a href="classstefanfrings_1_1Template.html#ad04721f62e02a81b84a56413e72387ad">More...</a><br /></td></tr>
<tr class="separator:ad04721f62e02a81b84a56413e72387ad"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1b3ed40800e941371edab3501daa450a"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1Template.html#a1b3ed40800e941371edab3501daa450a">loop</a> (QString name, const int repetitions)</td></tr>
<tr class="memdesc:a1b3ed40800e941371edab3501daa450a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set number of repetitions of a loop.  <a href="classstefanfrings_1_1Template.html#a1b3ed40800e941371edab3501daa450a">More...</a><br /></td></tr>
<tr class="separator:a1b3ed40800e941371edab3501daa450a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5f21e4c7a3a49d6c5339aba533713cc3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1Template.html#a5f21e4c7a3a49d6c5339aba533713cc3">enableWarnings</a> (const bool enable=true)</td></tr>
<tr class="memdesc:a5f21e4c7a3a49d6c5339aba533713cc3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enable warnings for missing tags.  <a href="classstefanfrings_1_1Template.html#a5f21e4c7a3a49d6c5339aba533713cc3">More...</a><br /></td></tr>
<tr class="separator:a5f21e4c7a3a49d6c5339aba533713cc3"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Enhanced version of QString for template processing. </p>
<p>Templates are usually loaded from files, but may also be loaded from prepared Strings. Example template file: </p>
<p><code></p><pre>
Hello {username}, how are you?

{if locked}
    Your account is locked.
{else locked}
    Welcome on our system.
{end locked}

The following users are on-line:
    Username       Time
{loop user}
    {user.name}    {user.time}
{end user}
</pre><p></code></p>
<p>Example code to fill this template: </p>
<p><code></p><pre>
<a class="el" href="classstefanfrings_1_1Template.html" title="Enhanced version of QString for template processing.">Template</a> t(QFile("test.tpl"),QTextCode::codecForName("UTF-8"));
t.setVariable("username", "Stefan");
t.setCondition("locked",false);
t.loop("user",2);
t.setVariable("user0.name","Markus");
t.setVariable("user0.time","8:30");
t.setVariable("user1.name","Roland");
t.setVariable("user1.time","8:45");
</pre><p></code></p>
<p>The code example above shows how variable within loops are numbered. Counting starts with 0. Loops can be nested, for example: </p>
<p><code></p><pre>
&lt;table&gt;
{loop row}
    &lt;tr&gt;
    {loop row.column}
        &lt;td&gt;{row.column.value}&lt;/td&gt;
    {end row.column}
    &lt;/tr&gt;
{end row}
&lt;/table&gt;
</pre><p></code></p>
<p>Example code to fill this nested loop with 3 rows and 4 columns: </p>
<p><code></p><pre>
t.loop("row",3);

t.loop("row0.column",4);
t.setVariable("row0.column0.value","a");
t.setVariable("row0.column1.value","b");
t.setVariable("row0.column2.value","c");
t.setVariable("row0.column3.value","d");

t.loop("row1.column",4);
t.setVariable("row1.column0.value","e");
t.setVariable("row1.column1.value","f");
t.setVariable("row1.column2.value","g");
t.setVariable("row1.column3.value","h");

t.loop("row2.column",4);
t.setVariable("row2.column0.value","i");
t.setVariable("row2.column1.value","j");
t.setVariable("row2.column2.value","k");
t.setVariable("row2.column3.value","l");
</pre><p></code></p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classstefanfrings_1_1TemplateLoader.html" title="Loads localized versions of template files.">TemplateLoader</a> </dd>
<dd>
<a class="el" href="classstefanfrings_1_1TemplateCache.html" title="Caching template loader, reduces the amount of I/O and improves performance on remote file systems.">TemplateCache</a> </dd></dl>

<p class="definition">Definition at line <a class="el" href="template_8h_source.html#l00091">91</a> of file <a class="el" href="template_8h_source.html">template.h</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a2b1b210dc7dac0ebe15f2ae4de6e0f89"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2b1b210dc7dac0ebe15f2ae4de6e0f89">&#9670;&nbsp;</a></span>Template() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Template::Template </td>
          <td>(</td>
          <td class="paramtype">const QString&#160;</td>
          <td class="paramname"><em>source</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QString&#160;</td>
          <td class="paramname"><em>sourceName</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Constructor that reads the template from a string. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">source</td><td>The template source text </td></tr>
    <tr><td class="paramname">sourceName</td><td>Name of the source file, used for logging </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="template_8cpp_source.html#l00011">11</a> of file <a class="el" href="template_8cpp_source.html">template.cpp</a>.</p>

</div>
</div>
<a id="a29a11e25a992928fb324671ee72a6f31"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a29a11e25a992928fb324671ee72a6f31">&#9670;&nbsp;</a></span>Template() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Template::Template </td>
          <td>(</td>
          <td class="paramtype">QFile &amp;&#160;</td>
          <td class="paramname"><em>file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QTextCodec *&#160;</td>
          <td class="paramname"><em>textCodec</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Constructor that reads the template from a file. </p>
<p>Note that this class does not cache template files by itself, so using this constructor is only recommended to be used on local filesystem. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>File that provides the source text </td></tr>
    <tr><td class="paramname">textCodec</td><td>Encoding of the source </td></tr>
  </table>
  </dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classstefanfrings_1_1TemplateLoader.html" title="Loads localized versions of template files.">TemplateLoader</a> </dd>
<dd>
<a class="el" href="classstefanfrings_1_1TemplateCache.html" title="Caching template loader, reduces the amount of I/O and improves performance on remote file systems.">TemplateCache</a> </dd></dl>

<p class="definition">Definition at line <a class="el" href="template_8cpp_source.html#l00018">18</a> of file <a class="el" href="template_8cpp_source.html">template.cpp</a>.</p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a5f21e4c7a3a49d6c5339aba533713cc3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5f21e4c7a3a49d6c5339aba533713cc3">&#9670;&nbsp;</a></span>enableWarnings()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Template::enableWarnings </td>
          <td>(</td>
          <td class="paramtype">const bool&#160;</td>
          <td class="paramname"><em>enable</em> = <code>true</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Enable warnings for missing tags. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">enable</td><td>Warnings are enabled, if true </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="template_8cpp_source.html#l00239">239</a> of file <a class="el" href="template_8cpp_source.html">template.cpp</a>.</p>

</div>
</div>
<a id="a1b3ed40800e941371edab3501daa450a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1b3ed40800e941371edab3501daa450a">&#9670;&nbsp;</a></span>loop()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Template::loop </td>
          <td>(</td>
          <td class="paramtype">QString&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int&#160;</td>
          <td class="paramname"><em>repetitions</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set number of repetitions of a loop. </p>
<p>This affects tags with the syntax</p>
<ul>
<li>{loop name}...{end name}</li>
<li>{loop name}...{else name}...{end name}</li>
</ul>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>Name of the loop </td></tr>
    <tr><td class="paramname">repetitions</td><td>The number of repetitions </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of loops that have been processed </dd></dl>

<p class="definition">Definition at line <a class="el" href="template_8cpp_source.html#l00155">155</a> of file <a class="el" href="template_8cpp_source.html">template.cpp</a>.</p>

</div>
</div>
<a id="ad04721f62e02a81b84a56413e72387ad"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad04721f62e02a81b84a56413e72387ad">&#9670;&nbsp;</a></span>setCondition()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Template::setCondition </td>
          <td>(</td>
          <td class="paramtype">const QString&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set a condition. </p>
<p>This affects tags with the syntax</p>
<ul>
<li>{if name}...{end name}</li>
<li>{if name}...{else name}...{end name}</li>
<li>{ifnot name}...{end name}</li>
<li>{ifnot name}...{else name}...{end name}</li>
</ul>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>Name of the condition </td></tr>
    <tr><td class="paramname">value</td><td>Value of the condition </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The count of conditions that have been processed </dd></dl>

<p class="definition">Definition at line <a class="el" href="template_8cpp_source.html#l00057">57</a> of file <a class="el" href="template_8cpp_source.html">template.cpp</a>.</p>

</div>
</div>
<a id="a6700fe0bdbf9955ad24f71bcba76604c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6700fe0bdbf9955ad24f71bcba76604c">&#9670;&nbsp;</a></span>setVariable()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Template::setVariable </td>
          <td>(</td>
          <td class="paramtype">const QString&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QString&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Replace a variable by the given value. </p>
<p>Affects tags with the syntax</p>
<ul>
<li>{name}</li>
</ul>
<p>After settings the value of a variable, the variable does not exist anymore, it it cannot be changed multiple times. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>name of the variable </td></tr>
    <tr><td class="paramname">value</td><td>new value </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The count of variables that have been processed </dd></dl>

<p class="definition">Definition at line <a class="el" href="template_8cpp_source.html#l00039">39</a> of file <a class="el" href="template_8cpp_source.html">template.cpp</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>templateengine/<a class="el" href="template_8h_source.html">template.h</a></li>
<li>templateengine/<a class="el" href="template_8cpp_source.html">template.cpp</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><b>stefanfrings</b></li><li class="navelem"><a class="el" href="classstefanfrings_1_1Template.html">Template</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
